package com.feng.newconfig.config.feign;

import com.alibaba.csp.sentinel.SphU;
import feign.Feign;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;

/**
 * @author yinglong.zhang
 * @description
 * @date 2024-1-17 15:21
 */
//@Configuration
public class FeignSentinelConfig {
    @Bean
    @Scope("prototype")
    @ConditionalOnClass({SphU.class, Feign.class})
    @ConditionalOnMissingBean
    @ConditionalOnProperty(name = {"creis.feign.sentinel.enabled"},matchIfMissing = true)
    @Primary
    public Feign.Builder feignSentinelBuilder() {
        return CloudSentinelFeign.builder();
    }
}
